package com.hornsun.util;

import com.hornsun.configInfo.ConfigInfo;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Random;

/**
 * Created by 编译中... on 2018/4/25.
 */
@Component
public class LittleUtil {

    @Autowired
    private ConfigInfo configInfo;

    public  RowBounds littleRowBounds(int page){
        int offset = (page-1)*configInfo.getLimit();
        int limite = configInfo.getLimit();
        return new RowBounds(offset,limite);
    }

    public  RowBounds bigRowBounds(int page){
        int offset = (page-1)*configInfo.getLimit1();
        int limite1 = configInfo.getLimit1();
        return new RowBounds(offset,limite1);
    }

    public static int getRandom(int count){
        Random random = new Random();
        return random.nextInt(count);
    }

}
